package com.botarena.client.ui;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Panel;
import com.google.gwt.user.client.ui.VerticalPanel;

public class SourceViewDialogBox extends DialogBox {
	
	public SourceViewDialogBox(String name, String source) {
		setAnimationEnabled(true);
		setGlassEnabled(true);
		setAutoHideEnabled(true);
		addStyleName("sourceCodeDialog");
		setText(name +"'s source");
		
		HTML sourceHTML = new HTML("<pre class=\"brush: py; class-name: 'sh-style'\">" + source + "</pre>");
		sourceHTML.addStyleName("sh-style");
		
		Button buttonOK = new Button("OK");
		buttonOK.addClickHandler(new ClickHandler() {
			public void onClick(ClickEvent event) {
				SourceViewDialogBox.this.hide();
			}
		});

		Panel panel = new VerticalPanel();
		panel.add(sourceHTML);
		panel.add(buttonOK);
		
		setWidget(panel);
	}
		
	@Override
	public void show() {
		super.show();
		Highlighter.highlight();
	}
}
